package com.mygame.center;

import com.mygame.common.component.BaseRoute;
import com.mygame.common.component.RouteComponent;
import com.mygame.common.utils.PathUtil;
import com.mygame.common.utils.PropertyReader;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import java.util.Collection;

@SpringBootApplication(scanBasePackages = {"com.mygame"})
@EnableMongoRepositories(basePackages = {"com.mygame"})
//@SpringBootApplication(scanBasePackages= {"com.mygame"},exclude= {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
public class WebGameCenterServerMain {

    public static void main(String[] args) throws Exception{
//        SpringContext.init(WebGameCenterServerMain.class);

        String configPath = PathUtil.getConfigBasePath("game_center");
        PropertyReader.addFolder(configPath);
        PropertyReader.init();
//        new ClassPathXmlApplicationContext(new String[] {
//                "spring-context.xml"
//        });

//        GameEventSystem.start(SpringContext.context);
        SpringApplication.run(WebGameCenterServerMain.class, args);

        GameEngine.createApp("","","");
        GameEngine.me().addComponent(new RouteComponent());

        Collection<BaseRoute> baseRoutes = SpringContext.getBeanListOfType(BaseRoute.class);
        GameEngine.me().route().putAll(baseRoutes);
    }
}


//不想在服务启动的时候初始化数据库的连接信息
